home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: HELP!!!!!!!
- Date: 03 Feb 1996 17:03:24 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb3100324@qcd.lanl.gov>
- References: <3112CFDA.85@utoronto.ca>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: Dave Goldstein's message of Sat, 3 Feb 1996 03:00:42 GMT
-
- In article <3112CFDA.85@utoronto.ca> Dave Goldstein
- <dave.goldstein@utoronto.ca> writes:
- <snip>
- I am a frustrated new C programmer, with a big headache:
- I've composed a linked list in a function, and I am passing the HEAD of
- the list into the function. Of course, when I pass this into the
- function, I have to dereference it twice (**head) since I pass it in as
- &head. Anyway, to make a long story short, when I try accessing the
- first item in the linked list (assuming there is one), I have tried
- accessing it as **head->next which C doesn't seem to like. WHY????!!
- It keeps giving me an error "Pointer to structure required on left side
- of -> or ->* in function ....". Isn't that what I'm doing??
-
- Please help, I'm beginning to feel suicidal!
-
- You would be well advised to post code instead of committing
- suicide. Do not assume we are mind readers ... show us what you are
- doing.
-
- Also be advised that your compiler seems to be willing to accept C++
- code. C and C++ are different languages: make up your mind which you
- are learning. A new C programmer does not need to know C++, and many
- believe the converse is also true. (It is quite possible that I am
- mistaken and your compiler will actually warn you if you use C++
- constructs.)
-
- As to your original question, given
-
- struct X a; you may refer to the fields as a.f or (&a)->f
- struct X *b; you may refer to the fields as b->f or (*b).f
- struct X **c; you may refer to the fields as (*c)->f or (**c).f
-
- etc.
-
- Hope you see the pattern.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-